package com.lmonkey.servlet.forget;

import com.lmonkey.servic.USERDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/shangc/remimaupdate")
public class RemimaUpdate extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");
        //获取数据
        String newmima = request.getParameter("newmima");
        String name = request.getParameter("name");

        //修改密码
        int count = 0;
        count = USERDao.updateMima(newmima,name);


        //跳转页面
         PrintWriter out = response.getWriter();
        if (count>0){
            out.println("<script>alert('修改成功');location.href='login.jsp'</script>");
            out.close();
        }else{
            out.println("<script>alert('修改失败');location.href='forget.jsp'</script>");
            out.close();
        }

    }
}
